﻿@using zichan.Entity.View
@using zichan.Common;
@model IPagedList<StaffView>
@{
    ViewBag.Title = "职员管理";
}

@section Pagetitle{
    @AdminCommon.PageTitle("职员管理", "列表/授权")
}
<style>
    #pagebar li {
        display: inline-block;
    }
</style>
<div class="portlet">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-table"></i>职员列表
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-container">

            <div class="dataTables_wrapper dataTables_extended_wrapper no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-group-actions pull-right">
                            @using (Html.BeginForm("index", "staff", FormMethod.Get, new { @class = "form-inline" }))
                            {
                                <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                <div class="form-group">
                                    <input type="text" placeholder="职员名称" name="name" value="@ViewBag.name" class="form-control input-small input-sm" />
                                </div>
                                <div class="form-group">
                                    <input type="text" placeholder="部门名称" name="departmentName" value="@ViewBag.departmentName" class="form-control input-sm" />
                                </div>
                                <div class="form-group">
                                    @Html.DropDownList("roleId", (SelectList)ViewBag.Roles, "角色...", new { @class = "form-control form-filter input-sm" })
                                </div>
                                <button class="btn btn-sm yellow table-group-action-submit"><i class="fa fa-check"></i> 搜索</button>
                            }
                        </div>
                    </div>
                </div>

                <div class="table-scrollable">
                    <table class="table  table-hover">
                        <thead>
                            <tr class="heading">
                                <th style=" width:30px;"> # </th>
                                <th>名称</th>
                                <th>部门</th>
                                <th>角色</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (StaffView s in Model)
                            {
                                <tr>
                                    <td>@s.Id</td>
                                    <td>@s.Name</td>
                                    <td>@s.DepartmentName</td>
                                    <td>@s.RoleNames</td>
                                    <td>
                                        @if (PowerHelp.Check("staff", "auth"))
                                        {
                                            <a href="@Url.Action("auth", "staff", new  { Id=s.Id})" class="btn default btn-xs purple">
                                                <i class="fa fa-key"></i> 授权管理
                                            </a>
                                        }
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <div class="col-sm-12 dataTables_paginate">
                        <div class="pull-right">
                            <ul id="pagebar" style="display:inline-block;margin-right:10px;">
                                <li>
                                    每页<select name="pageSize" id="pageSize" class="select2" style="width:50px;font-size:18px;">
                                        <option value="@ViewBag.pageSize">@ViewBag.pageSize</option>
                                        @foreach (var s in ViewBag.pageSizes)
                                        {
                                            <option value="@s.Value">@s.Text</option>
                                        }
                                    </select>个
                                </li>
                                <li>第@(Model.PageNumber)/共@(Model.PageCount)页</li>
                                @using (Html.BeginForm("index", "Staff", FormMethod.Get, new { @style = "display: inline-block;" }))
                                {
                                    <li style="display:none;">
                                        <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                        <input type="hidden" name="name" value="@ViewBag.name" />
                                        <input type="hidden" name="departmentName" value="@ViewBag.departmentName" />
                                        <input type="hidden" name="roleId" value="@ViewBag.roleId" />
                                        @Html.TextBox("pageCount", Model.PageCount)
                                    </li>
                                    <li>跳转至<input name="selectedPage" style="width:40px;font-size:18px;" value="@ViewBag.selectedPage" />页</li>
                                    <li><button type="submit">GO</button></li>}
                            </ul>
@if (Model.PageCount > 1)
{
                            <ul id="pagebar" class="pagination" style="margin:0px;float:right;">
                                <li><a href="@Url.Action("Index", "Staff", new { name = ViewBag.name, departmentName = ViewBag.departmentName, roleId = ViewBag.roleId,pageSize = ViewBag.pageSize, page = 1 })">首页</a></li>
                                <li>@Html.ActionLink("上一页", "Index", "Staff", new { name = ViewBag.name, departmentName = ViewBag.departmentName, roleId = ViewBag.roleId, pageSize = ViewBag.pageSize, page = Model.PageNumber - 1 }, null)</li>
                                <li>@Html.ActionLink("下一页", "Index", "Staff", new { name = ViewBag.name, departmentName = ViewBag.departmentName, roleId = ViewBag.roleId, pageSize = ViewBag.pageSize, page = (Model.PageNumber + 1 < Model.PageCount ? Model.PageNumber + 1 : Model.PageCount) }, null)</li>
                                <li>@Html.ActionLink("末页", "Index", "Staff", new { name = ViewBag.name, departmentName = ViewBag.departmentName, roleId = ViewBag.roleId, pageSize = ViewBag.pageSize, page = Model.PageCount }, null)</li>
                            </ul>}
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
@section footer{
    <script type="text/javascript">
        $(function () {
            $('#pageSize').on("change", function () {
                var name = $("input[name='name']").val();
                var departmentName = $("input[name='departmentName']").val();
                var roleId = $("input[name='roleId']").val();
                var size = $(this).val();
                location.href = "/Staff/Index?name=" + name + "&departmentName=" + departmentName + "&roleId=" + roleId+ "&pageSize=" + size;
            });

        });
    </script>
}








